/*

Replication code for Ben Cormier and Natalya Naqvi, "Delegating Discipline" forthcoming. Journal of Politics. 
Code for Appendix work.
Note: requires estout package & bacondecomp package; bacondecomp run on STATA 15.

*/


**************
*Data and set*
**************
use "data1_redacted.dta", clear
xtset country_num year
set scheme s1mono
grstyle init
grstyle set plain, nogrid 


******************************************
*Appendix A: Descriptive Statistics
*Eligible country-year observations only
******************************************
keep if Eligible_LorMIC_2yrsRunning == 1
tabstat issuancePerOfExtBwng HardInclusionDummy hardIndex_AnnAvg GDPpcap GDPgrowth Inflation ExtDebtStock ka_open FinancialDepth Def_PerGDP Crtg_BestOf v2x_libdem v2cltrnslw LeftNew2yrs annavg_UStrasuryIntRate ///
, stat(n mean med mi ma sd iqr) case col(stat)


******************************************
*Appendix B: List Eligible Country-Years Full Observations 
*i.e. list of observations of eligible EMs with complete data for all covariates
******************************************
regress issuancePerOfExtBwng l.GDPpcap l.GDPgrowth l.Inflation l.ExtDebtStock l.ka_open l.FinancialDepth l.Def_PerGDP l.Crtg_BestOf l.v2x_libdem l.v2cltrnslw l.LeftNew2yrs l.annavg_UStrasuryIntRate
gen in_model = e(sample)
keep if in_model==1
export excel using "FullCtyYrs.xlsx", replace


******************************************
*Appendix Ci: Bacon-Goodman DID Decomposition
*Reset to full data
******************************************
use "data1_redacted.dta", clear
xtset country_num year
*Get balanced panel, based on if L/MIC in 1991
generate HIC1991 = 1 if year == 1991 & HIC == 1
bysort country_num (HIC1991) : keep if missing(HIC1991[1])
xtset country_num year
*Delete any NAs
regress ln_gt1yr_byYear HardInclusionDummy
gen complete = 1 if e(sample)
keep if complete == 1
xtset country_num year
*Bacon decomp with balanced panel of L/MICs
set matsize 800
bacondecomp ln_gt1yr_byYear HardInclusionDummy, ddetail


******************************************
*Appendix Cii: Chow Tests
******************************************
regress issuancePerOfExtBwng HardInclusionDummy##c.l.GDPpcap HardInclusionDummy##c.l.ExtDebtStock HardInclusionDummy##c.l.Def_PerGDP HardInclusionDummy##c.l.LeftNew2yrs HardInclusionDummy##c.l.annavg_UStrasuryIntRate
contrast HardInclusionDummy HardInclusionDummy#c.l.GDPpcap HardInclusionDummy#c.l.ExtDebtStock HardInclusionDummy#c.l.Def_PerGDP HardInclusionDummy#c.l.LeftNew2yrs HardInclusionDummy#c.l.annavg_UStrasuryIntRate, overall


******************************************
*Appendix D: Yield Models
*Load country-quarer panel data with quarterly yield data
******************************************
use "qtrlyData1_redacted.dta", clear
xtset country_num quarter

*Initial Model
heckman logYieldsQtrly l.GDPpcap l.GDPgrowth l.Inflation l.ExtDebtStock l.ka_open l.FinancialDepth l.Def_PerGDP l.Crtg_BestOf l.v2x_libdem l.v2cltrnslw l.LeftNew l.annavg_UStrasuryIntRate i.country_num i.quarter, ///
select(Eligible_LorMIC_2yrsRunning = l.GDPpcap l2.GDPpcap l3.GDPpcap l.Crtg_BestOf l2.Crtg_BestOf l3.Crtg_BestOf post2005dummy l.HardInclusionDummy) twostep
est store weightPriceID
*Table
esttab weightPriceID using Price1_InitialID.csv, replace /// 
varlabels("HardInclusionDummy" "IndexInclusion" "Def_PerGDP" "Deficit" "v2x_libdem" "Democracy" "Crtg_BestOf" "CreditRating" "v2cltrnslw" "Transparency" "ExtDebtStock" "DebtLevels" "annavg_UStrasuryIntRate" "USIRates" "LeftNew2yrs" "NewLeftGovt" "FinancialDepth" "DomFinDepth") ///
cells(b(star fmt(%9.3f)) se(par)) stats(N) starlevels(* 0.05 ** 0.01 *** 0.001) nonumbers legend /// 
title("Initial Model of Effects on Price") /// 
note("Country and Quarter fixed effects" "Heckman twostep standard errors" "All variables lagged")

*Interaction
heckman logYieldsQtrly l.GDPpcap c.hardIndex_AnnAvg##c.l.GDPgrowth l.Inflation c.hardIndex_AnnAvg##c.l.ExtDebtStock c.hardIndex_AnnAvg##c.l.ka_open l.FinancialDepth l.Def_PerGDP c.hardIndex_AnnAvg##c.l.Crtg_BestOf l.v2x_libdem l.v2cltrnslw l.LeftNew c.hardIndex_AnnAvg##c.l.annavg_UStrasuryIntRate i.country_num i.quarter, ///
select(Eligible_LorMIC_2yrsRunning = l.GDPpcap l2.GDPpcap l3.GDPpcap l.Crtg_BestOf l2.Crtg_BestOf l3.Crtg_BestOf post2005dummy l.HardInclusionDummy) twostep
est store weightPriceInteractions
*Table
esttab weightPriceInteractions using Price2_Interact.csv, replace /// 
varlabels("HardInclusionDummy" "IndexInclusion" "Def_PerGDP" "Deficit" "v2x_libdem" "Democracy" "Crtg_BestOf" "CreditRating" "v2cltrnslw" "Transparency" "ExtDebtStock" "DebtLevels" "annavg_UStrasuryIntRate" "USIRates" "LeftNew2yrs" "NewLeftGovt" "FinancialDepth" "DomFinDepth") ///
cells(b(star fmt(%9.3f)) se(par)) stats(N) starlevels(* 0.05 ** 0.01 *** 0.001) nonumbers legend /// 
title("Interaction Effects on Price") /// 
note("Country and Quarter fixed effects" "Heckman twostep standard errors" "All variables lagged")


******************************************
*Appendix Ei & Eii: No Lag Models
*Re-load country-year panel data
******************************************
use "data1_redacted.dta", clear
xtset country_num year

*Dummy Interaction No Lag
heckman issuancePerOfExtBwng i.HardInclusionDummy##c.GDPpcap GDPgrowth Inflation i.HardInclusionDummy##c.ExtDebtStock ka_open FinancialDepth i.HardInclusionDummy##c.Def_PerGDP Crtg_BestOf v2x_libdem v2cltrnslw i.HardInclusionDummy##c.LeftNew2yrs i.HardInclusionDummy##c.annavg_UStrasuryIntRate i.country_num i.year, ///
select(Eligible_LorMIC_2yrsRunning = l.GDPpcap l2.GDPpcap l3.GDPpcap l.Crtg_BestOf l2.Crtg_BestOf l3.Crtg_BestOf post2005dummy l.HardInclusionDummy) twostep
est store dummyNoLags
*Table
esttab dummyNoLags using NoLags_Dummy.csv, replace /// 
varlabels("HardInclusionDummy" "IndexInclusion" "Def_PerGDP" "Deficit" "v2x_libdem" "Democracy" "Crtg_BestOf" "CreditRating" "v2cltrnslw" "Transparency" "ExtDebtStock" "DebtLevels" "annavg_UStrasuryIntRate" "USIRates" "LeftNew2yrs" "NewLeftGovt" "FinancialDepth" "DomFinDepth") ///
cells(b(star fmt(%9.3f)) se(par)) stats(N) starlevels(* 0.05 ** 0.01 *** 0.001) nonumbers legend /// 
title("No Lag Dummy Interaction Models") /// 
note("Country and Year fixed effects" "Heckman twostep standard errors")

*Weight Interaction No Lag
heckman issuancePerOfExtBwng c.hardIndex_AnnAvg##c.GDPpcap GDPgrowth Inflation c.hardIndex_AnnAvg##c.ExtDebtStock ka_open FinancialDepth c.hardIndex_AnnAvg##c.Def_PerGDP Crtg_BestOf v2x_libdem v2cltrnslw c.hardIndex_AnnAvg##c.LeftNew2yrs c.hardIndex_AnnAvg##c.annavg_UStrasuryIntRate  i.country_num i.year, ///
select(Eligible_LorMIC_2yrsRunning = l.GDPpcap l2.GDPpcap l3.GDPpcap l.Crtg_BestOf l2.Crtg_BestOf l3.Crtg_BestOf post2005dummy l.HardInclusionDummy) twostep
est store weightNoLags
*Table
esttab weightNoLags using NoLags_Weights.csv, replace /// 
varlabels("HardInclusionDummy" "IndexInclusion" "Def_PerGDP" "Deficit" "v2x_libdem" "Democracy" "Crtg_BestOf" "CreditRating" "v2cltrnslw" "Transparency" "ExtDebtStock" "DebtLevels" "annavg_UStrasuryIntRate" "USIRates" "LeftNew2yrs" "NewLeftGovt" "FinancialDepth" "DomFinDepth") ///
cells(b(star fmt(%9.3f)) se(par)) stats(N) starlevels(* 0.05 ** 0.01 *** 0.001) nonumbers legend /// 
title("No Lag Weight Interaction Models") /// 
note("Country and Year fixed effects" "Heckman twostep standard errors")


******************************************
*Appendix Eiii: ka_open Test
******************************************
heckman issuancePerOfExtBwng i.HardInclusionDummy##c.l.GDPpcap l.GDPgrowth l.Inflation i.HardInclusionDummy##c.l.ExtDebtStock i.HardInclusionDummy##c.l.ka_open l.FinancialDepth i.HardInclusionDummy##c.l.Def_PerGDP l.Crtg_BestOf l.v2x_libdem l.v2cltrnslw i.HardInclusionDummy##c.l.LeftNew2yrs i.HardInclusionDummy##c.l.annavg_UStrasuryIntRate  i.country_num i.year, ///
select(Eligible_LorMIC_2yrsRunning = l.GDPpcap l2.GDPpcap l3.GDPpcap l.Crtg_BestOf l2.Crtg_BestOf l3.Crtg_BestOf post2005dummy l.HardInclusionDummy) twostep
est store kaTest
*Table
esttab kaTest using ka_test.csv, replace /// 
varlabels("HardInclusionDummy" "IndexInclusion" "Def_PerGDP" "Deficit" "v2x_libdem" "Democracy" "Crtg_BestOf" "CreditRating" "v2cltrnslw" "Transparency" "ExtDebtStock" "DebtLevels" "annavg_UStrasuryIntRate" "USIRates" "LeftNew2yrs" "NewLeftGovt" "FinancialDepth" "DomFinDepth") ///
cells(b(star fmt(%9.3f)) se(par)) stats(N) starlevels(* 0.05 ** 0.01 *** 0.001) nonumbers legend /// 
title("ka_open Interaction Test") /// 
note("Country and Year fixed effects" "Heckman twostep standard errors" "All variables lagged")


******************************************
*Appendix Eiv: Add commercial bank loans to the DV 
*issuancePerOfExtBwng_wBanks2
******************************************
*ID Initial Significance
heckman issuancePerOfExtBwng_wBanks2 l.GDPpcap l.GDPgrowth l.Inflation l.ExtDebtStock l.ka_open l.FinancialDepth l.Def_PerGDP l.Crtg_BestOf l.v2x_libdem l.v2cltrnslw l.LeftNew2yrs l.annavg_UStrasuryIntRate i.country_num i.year, ///
select(Eligible_LorMIC_2yrsRunning = l.GDPpcap l2.GDPpcap l3.GDPpcap l.Crtg_BestOf l2.Crtg_BestOf l3.Crtg_BestOf post2005dummy l.HardInclusionDummy) twostep
est store bankInitial
*Table
esttab bankInitial using BankDV_initial.csv, replace /// 
varlabels("HardInclusionDummy" "IndexInclusion" "Def_PerGDP" "Deficit" "v2x_libdem" "Democracy" "Crtg_BestOf" "CreditRating" "v2cltrnslw" "Transparency" "ExtDebtStock" "DebtLevels" "annavg_UStrasuryIntRate" "USIRates" "LeftNew2yrs" "NewLeftGovt" "FinancialDepth" "DomFinDepth") ///
cells(b(star fmt(%9.3f)) se(par)) stats(N) starlevels(* 0.05 ** 0.01 *** 0.001) nonumbers legend /// 
title("Banks in DV, Initial Models") /// 
note("Country and Year fixed effects" "Heckman twostep standard errors")

*Dummy Interactions
heckman issuancePerOfExtBwng_wBanks2 i.HardInclusionDummy##c.GDPpcap GDPgrowth Inflation i.HardInclusionDummy##c.ExtDebtStock ka_open FinancialDepth i.HardInclusionDummy##c.Def_PerGDP Crtg_BestOf v2x_libdem v2cltrnslw i.HardInclusionDummy##c.LeftNew2yrs i.HardInclusionDummy##c.annavg_UStrasuryIntRate i.country_num i.year, ///
select(Eligible_LorMIC_2yrsRunning = l.GDPpcap l2.GDPpcap l3.GDPpcap l.Crtg_BestOf l2.Crtg_BestOf l3.Crtg_BestOf post2005dummy l.HardInclusionDummy) twostep
est store bankDummy
*Table
esttab bankDummy using BankDV_dummy.csv, replace /// 
varlabels("HardInclusionDummy" "IndexInclusion" "Def_PerGDP" "Deficit" "v2x_libdem" "Democracy" "Crtg_BestOf" "CreditRating" "v2cltrnslw" "Transparency" "ExtDebtStock" "DebtLevels" "annavg_UStrasuryIntRate" "USIRates" "LeftNew2yrs" "NewLeftGovt" "FinancialDepth" "DomFinDepth") ///
cells(b(star fmt(%9.3f)) se(par)) stats(N) starlevels(* 0.05 ** 0.01 *** 0.001) nonumbers legend /// 
title("Banks in DV, Dummy Interactions") /// 
note("Country and Year fixed effects" "Heckman twostep standard errors")

*Weight Interactions
heckman issuancePerOfExtBwng_wBanks2 c.hardIndex_AnnAvg##c.GDPpcap GDPgrowth Inflation c.hardIndex_AnnAvg##c.ExtDebtStock ka_open FinancialDepth c.hardIndex_AnnAvg##c.Def_PerGDP Crtg_BestOf v2x_libdem v2cltrnslw c.hardIndex_AnnAvg##c.LeftNew2yrs c.hardIndex_AnnAvg##c.annavg_UStrasuryIntRate  i.country_num i.year, ///
select(Eligible_LorMIC_2yrsRunning = l.GDPpcap l2.GDPpcap l3.GDPpcap l.Crtg_BestOf l2.Crtg_BestOf l3.Crtg_BestOf post2005dummy l.HardInclusionDummy) twostep
est store bankWeight
*Table
esttab bankWeight using BankDV_weight.csv, replace /// 
varlabels("HardInclusionDummy" "IndexInclusion" "Def_PerGDP" "Deficit" "v2x_libdem" "Democracy" "Crtg_BestOf" "CreditRating" "v2cltrnslw" "Transparency" "ExtDebtStock" "DebtLevels" "annavg_UStrasuryIntRate" "USIRates" "LeftNew2yrs" "NewLeftGovt" "FinancialDepth" "DomFinDepth") ///
cells(b(star fmt(%9.3f)) se(par)) stats(N) starlevels(* 0.05 ** 0.01 *** 0.001) nonumbers legend /// 
title("Banks in DV, Weight Interactions") /// 
note("Country and Year fixed effects" "Heckman twostep standard errors")


******************************************
*Appendix Ev: CBI as control
******************************************
heckman issuancePerOfExtBwng l.GDPpcap l.GDPgrowth l.Inflation l.ExtDebtStock l.ka_open l.FinancialDepth l.Def_PerGDP l.Crtg_BestOf l.v2x_libdem l.v2cltrnslw l.LeftNew2yrs l.annavg_UStrasuryIntRate l.CBIraw i.country_num i.year, ///
select(Eligible_LorMIC_2yrsRunning = l.HardInclusionDummy) twostep
est store cbiAppendix
*Table
esttab cbiAppendix using cbi.csv, replace /// 
varlabels("HardInclusionDummy" "IndexInclusion" "Def_PerGDP" "Deficit" "v2x_libdem" "Democracy" "Crtg_BestOf" "CreditRating" "v2cltrnslw" "Transparency" "ExtDebtStock" "DebtLevels" "annavg_UStrasuryIntRate" "USIRates" "LeftNew2yrs" "NewLeftGovt" "FinancialDepth" "DomFinDepth") ///
cells(b(star fmt(%9.3f)) se(par)) stats(N) starlevels(* 0.05 ** 0.01 *** 0.001) nonumbers legend /// 
title("CBI test") /// 
note("Country and Year fixed effects" "Heckman twostep standard errors")





